import { defineStore } from 'pinia'
import { ref } from 'vue'

export const useActiveTabbarStore = defineStore(
  'activeTabbar',
  () => {
    const curIdx = ref(uni.getStorageSync('app-tabbar-index') || 0)
    const setCurIdx = (idx: number) => {
      curIdx.value = idx
      uni.setStorageSync('app-tabbar-index', idx)
    }
    return { setCurIdx, curIdx }
  },
  { persist: true },
)
